#ifndef MOCHA_DETAIL_GRAPHICS_HPP_INCLUDED
#define MOCHA_DETAIL_GRAPHICS_HPP_INCLUDED

/**
 * @file
 */

#include <string>
#include <boost/noncopyable.hpp>
#include "mocha/color.hpp"
#include "mocha/graphics_plugin.hpp"
#include "mocha/object_importer.hpp"
#include "mocha/plugin_proxy.hpp"
#include "mocha/pointers.hpp"

namespace mocha { namespace graphics {
/**
 * Graphics device.
 * Used to open a display mode and perform drawing operations.
 */
class graphics : public plugin_proxy<graphics_plugin>, public boost::noncopyable {
public:
	graphics(plugin_factory_ptr_t factory, const std::string& name, const object_importer& importer);
	~graphics();
	/**
	 * 
	 * @param caps 
	 * @return 
	 */
	int capabilities(graphics_caps& caps);
	/**
	 * Opens a display mode.
	 * Must be called before using the graphics device.
	 * Can be called again to attempt to change the display mode.
	 * @param width Width of the display in pixels.
	 * @param height Height of the display in pixels.
	 * @param full True for full screen mode. False for windowed mode (or best equivalent on the target platform).
	 * @return 
	 */
	int open_display_mode(size_t width, size_t height, bool full = false);
	/**
	 * Swaps the front and back buffers.
	 */
	void swap_buffers();
	/**
	 * Clears the back buffer.
	 * @param cc Color used to clear the buffer.
	 * @return 
	 */
	int clear_back_buffer(rgba_t cc = color_black);
	/**
	 * 
	 * @return 
	 */
	size_t push_transform();
	/**
	 * 
	 * @return 
	 */
	size_t pop_transform();
	//image_ptr_t create_image() const;
	//texture_ptr_t create_texture() const;
};
/**
 * 
 */
class push_pop_transform {
public:
	push_pop_transform(graphics_ptr_t gfx): gfx_(gfx) {
		gfx_->push_transform();
	}
	~push_pop_transform() {
		gfx_->pop_transform();
	}
private:
	graphics_ptr_t gfx_;
};
}}

#endif

